﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Resto.CostControl.Common.Utility
{
    public static class TimeHelper
    {
        /// <summary>
        /// 获取下周一的日期
        /// </summary>
        /// <returns></returns>
        public static DateTime GetNextMonday()
        {
            DateTime time = DateTime.Now;
            
            //星期天是0，星期一是1
            int i = time.DayOfWeek.GetHashCode();

            if (i == 0)
                return DateTime.Now.AddDays(1);
            else
                return DateTime.Now.AddDays(8 - i);

        }

        /// <summary>
        /// 将日期转化成2011-1-1 00:00:00的格式
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public static DateTime GetMinDateTime(DateTime time)
        {
            return time.Date;
        }

        /// <summary>
        /// 将日期转化成2011-1-1 23:59:59的格式
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public static DateTime GetMaxDateTime(DateTime time)
        {
            return time.Date.AddDays(1).AddSeconds(-1);
        }
    }
}
